﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace PlanningGIS.Win.Controls
{
  
    public partial class FrmYesOrNoQuery :Office2007Form
    {
        /// <summary>
        /// 
        /// </summary>
        private bool sameWay;
        /// <summary>
        /// 
        /// </summary>
        private int interval;
        /// <summary>
        /// 
        /// </summary>
        private int lapse = 0;
        /// <summary>
        /// 
        /// </summary>
        public bool SameWay
        {
            get { return sameWay; }
        }

        /// <summary>
        /// 倒计时，以秒为单位；到点无操作，默认选择“否”
        /// </summary>
        public int Interval
        {
            set
            {
                interval = value;
                timer1.Start();
                labTime.Text = "(" + interval + ")";
                Application.DoEvents();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public FrmYesOrNoQuery(string msg)
        {
            InitializeComponent();
            lblMsg.Text = msg;
            labTime.Text = "";
            btnNo.Focus();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnYes_Click(object sender, EventArgs e)
        {
            sameWay = chkSame.Checked;
            this.DialogResult = DialogResult.Yes;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNo_Click(object sender, EventArgs e)
        {
            sameWay = chkSame.Checked;
            this.DialogResult = DialogResult.No;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            lapse++;
            if (lapse < interval)
            {
                labTime.Text = "(" + (interval - lapse) + ")";
                Application.DoEvents();
            }
            else
            {
                this.DialogResult = DialogResult.No;
                timer1.Stop();
                this.Close();
            }
        }
    }
}
